<%@page import="cn.jhc.dao.NewUserDao"%>
<%@page import="cn.jhc.bean.EventBean"%>
<%@page import="cn.jhc.dao.ActivitiesDAO"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/houtai.css"></link>
<script type="text/javascript">
	function MM_popupMsg(msg) {
		alert(msg);
	}
</script>
<title>社团管理平台</title>
</head>
<body>
	<%
		int CurrentPage = 1;
		int intPageCount, intAllCount;
		if (request.getParameter("page") != null)
			CurrentPage = Integer.parseInt(request.getParameter("page"));
		if (CurrentPage < 1)
			CurrentPage = 1;
		int titleCount = 10;
	%>
	<div id="wrapper">
		<jsp:include page="./houtai_header.jsp"></jsp:include>
		<div id="left">
			<div class="button"><a href="houtai_news.jsp">新闻发布</a></div>
			<div class="button"><a href="houtai_announcement.jsp">公告发布</a></div>
			<div class="button2"><a href="houtai_activities.jsp">活动发布</a></div>
		</div>
		<%
			String Act_id = (String) request.getParameter("act_id");
			int act_id = Integer.parseInt(Act_id);
			ArrayList<EventBean> list = new ArrayList<EventBean>();
			NewUserDao dao = new NewUserDao();
			dao.setCon(ConnectionFactory.getConnection());
			list = dao.getAllEvent(act_id, CurrentPage, titleCount);
			request.setAttribute("event", list);
		%>
		<%
			NewUserDao dao2 = new NewUserDao();
			dao2.setCon(ConnectionFactory.getConnection());
			intPageCount = dao2.getCount(act_id, titleCount);
			if (intPageCount == 0) {
				CurrentPage = 1;
				intPageCount = 1;
			} else {
				if (CurrentPage > intPageCount)
					CurrentPage = intPageCount;
			}
		%>
		<%
			NewUserDao dao3 = new NewUserDao();
			dao3.setCon(ConnectionFactory.getConnection());
			intAllCount = dao3.getAllCount(act_id);
		%>
		<div id="right">
			<div id="right_top">
				<a>所在位置： 信息发布&gt;活动信息&gt;报名情况</a> <div id="num" align="right"><a>报名人数:<%=intAllCount%></a></div>
			</div>
			<div id="right_news">
				<table width="100%">
					<tr>
						<th height="25">姓名</th>
						<th>学院班级</th>
						<th>宿舍寝室</th>
						<th>联系电话</th>
						<th>联系邮箱</th>
						<th>报名日期</th>
						<th>操作</th>
					</tr>
					<c:forEach items="${requestScope.event}" var="event">
						<tr>
							<td height="25"><div align="center">
									<a>${event.name}</a>
								</div></td>
							<td><div align="center">${event.classname}</div></td>
							<td><div align="center">${event.room}</div></td>
							<td><div align="center">${event.phone}</div></td>
							<td><div align="center">${event.email}</div></td>
							<td><div align="center">${event.date}</div></td>
							<td><div align="center">
									<a href="./deleteEvent.do?id=${event.id }&&act_id=<%=act_id%>"
										onclick="MM_popupMsg('删除成功！')">删除</a>
								</div></td>
						</tr>
					</c:forEach>
				</table>
				<div align="right">
					<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
					</a> <a href="houtai_showevent.jsp?page=<%=1%>&&act_id=<%=act_id%>">首页</a>
					<%
						if (CurrentPage > 1) {
					%>
					<a
						href="houtai_showevent.jsp?page=<%=CurrentPage - 1%>&&act_id=<%=act_id%>">上一页</a>
					<%
						} else {
					%>
					上一页
					<%
						}
					%>
					<%
						if (CurrentPage >= intPageCount) {
					%>
					下一页
					<%
						} else {
					%>
					<a
						href="houtai_showevent.jsp?page=<%=CurrentPage + 1%>&&act_id=<%=act_id%>">下一页</a>
					<%
						}
					%>
					<a
						href="houtai_showevent.jsp?page=<%=intPageCount%>&&act_id=<%=act_id%>">末页</a>
				</div>
				<div id="button">
					<form method="post" action="./houtai_addactivities.jsp">
						<input type="submit" value="点此增加活动信息"></input>
					</form>
				</div>
			</div>
		</div>
	</div>
</body>
</html>